using System;

namespace DL.SearchAlgorithm
{
    public struct DfsPos
    {
        private int _posX;
        private int _posY;

        public int PosX => _posX;
        public int PosY => _posY;

        public DfsPos(int posX = 0, int posY = 0)
        {
            _posY = posY;
            _posX = posX;
        }

        public override string ToString()
        {
            return $"(X:{_posX},Y:{_posY})";
        }

        public override bool Equals(object obj)
        {
            return obj is DfsPos other && Equals(other);
        }

        public override int GetHashCode()
        {
            return HashCode.Combine(_posX, _posY);
        }
        
        public bool Equals(DfsPos other)
        {
            return _posX == other._posX && _posY == other._posY;
        }

        public static bool operator ==(DfsPos pos1, DfsPos pos2)
        {
            return pos1.Equals(pos2);
        }

        public static bool operator !=(DfsPos pos1, DfsPos pos2)
        {
            return !(pos1 == pos2);
        }
        
        public static DfsPos operator+(DfsPos pos1, DfsPos pos2)
        {
            return new DfsPos(pos1._posX + pos2._posX,pos1._posY + pos2._posY);
        }
    };
}
